<!DOCTYPE HTML>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>

<select id="menulist">
  <option id="item0">Alicia</option>
  <option id="item1">Peter</option>
  <option id="item2">Kalinda</option>
</select>

<script>
async_test((t) => {
    var menulist = document.getElementById("menulist");
    menulist.selectedIndex = 0;

    var result = "";
    accessibilityController.addNotificationListener(t.step_func(
        function(element, notification) {
            t.done();
            if (element.role != "AXRole: AXMenuListOption")
                return;

            if (element.name == "Alicia") {
                assert_equals(element.isSelected, false);
            } else if (element.name == "Kalinda") {
                assert_equals(element.isSelected, true);
                t.done();
            }
        }
    ));

    menulist.selectedIndex = 2;
}, "This test makes sure menu lists fire events on both the option that lost selection and the one that gained selection.");
</script>
